package com.bistu.openlab.uofspreadsheet.model;

import java.util.ArrayList;
import java.util.List;

/*
 *@author xiaoguang.gao@oracle.com
 *@version 2013-5-9 
 */
public class SheetRow {
	private int rowNum = 0;
	private List<SheetCell> cellList = null;
	
	public SheetRow(){}
	/**
	 * get a cell from a row
	 * @param cellid
	 * @return
	 */
	public SheetCell getCell(int cellid){
		if(this.cellList!=null){
			for(SheetCell cell : this.cellList){
				if(cell.getCellNum()==cellid)
					return cell;
			}
		}
		return null;
	}
	
	
	public void addSheetCell(SheetCell cell){
		if(this.cellList==null)
			this.cellList = new ArrayList<SheetCell>();
		this.cellList.add(cell);
	}
	public void removeSheetCell(SheetCell cell){
		if(this.cellList!=null){
			this.cellList.remove(cell);
			if(this.cellList.size()<=0)
				this.cellList = null;
		}
	}

	public int getRowNum() {
		return rowNum;
	}

	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}

	public List<SheetCell> getCellList() {
		return cellList;
	}

	public void setCellList(List<SheetCell> cellList) {
		this.cellList = cellList;
	}
}
